<%@ include file="/common/taglibs.jsp"%>
<%@ taglib prefix="sales" tagdir="/WEB-INF/tags/sales"%>
<%@ taglib prefix="catalog" tagdir="/WEB-INF/tags/catalog"%>
<%@ taglib prefix="eai" tagdir="/WEB-INF/tags/eai"%>

<content tag="buttons">
	<authorize:authorizeResource resourceString="/sales/gift*direct=add">
		<probiz:iconBtn btnType="save" onclick="saveGift(0);"  />
		<probiz:iconBtn btnType="save" btnTextKey="gift.button.saveAndReturnToList" onclick="saveGift(1);" id="saveAndReturn"/>
		<probiz:iconBtn btnType="save" btnTextKey="gift.button.saveAndAddSimilar" onclick="saveGift(2);" id="saveAndAddSimilar"/>
	</authorize:authorizeResource>
	<c:if test="${not empty gift.giftId}">
		<authorize:authorizeResource resourceString="/sales/gift.html?doAction=*elete*">
		 	<probiz:iconBtn btnType="delete" onclick="deleteGift();"/>
		</authorize:authorizeResource>
  	</c:if>
  	<probiz:iconBtn btnType="back" onclick="return fnDoCancelForm(this);" />
</content>

<div id="errorMsgExtraBar" class="warning_msg"  style="display: none"></div>
<div id="successMsgExtraBar" class="success_msg" style="display: none"></div>

<div class="top clearfix">
	<ul class="tab" id="detail">
		<li class="curr">
			<a href="#tab-summary"><span><fmt:message key="giftDetail.tab.summary" /> </span> </a>
		</li>
	</ul>
</div>
 	<div class="modify">
	<form id="giftForm" name="giftForm"	action="${ctxPath}/sales/gift.html">
		<div id="tab-summary">
			<div class="p_edit_basic">
				<table width="100%" border="0" cellspacing="0" cellpadding="0" class="com_modi_table">
					<tr>
						<th colspan="2" class="title"><h4><fmt:message key="giftDetail.group.basic"/></th>
					</tr>
					<tr>
						<td valign="top" width="550">				
       						<%@include file="include/giftFormSummary.jspf"%>
       					</td>
       					<td valign="top" id="areaOfImages">
						<div class="p_img">
							<div class="action_bar">
								<div class="cnt">
								<table width="100%" border="0" cellspacing="0" cellpadding="0">
									<tr>
										<td style="padding:0;width:100px;" id="addImagesBtn">
											<input type="hidden" id="imageUrl" name="imageUrl"	value="${gift.imageUrl}" />
										</td>
										<td style="text-align:right;"><fmt:message key="gift.imageUrl.title"/>:<fmt:message key="gift.imageUrl.tip"/></td>
									</tr>
								</table>
								</div>
							</div>
							<div class="main_pic">
								<div class="cnt">
									<div class="pic_area">
										<sales:giftImage id="giftImage" gift="${gift}" sizeType="m0" linkType="2" width="270" height="270"/>
									</div>
								</div>
							</div>
							<div class="all_pics" id="allPicsDiv" style="display:none;">
								<div class="cnt">
									<table border="0" cellspacing="0" cellpadding="0">
										<tr id="imageList">
										</tr>
									</table>
								</div>
							</div>
						</div>
       					</td>
       				</tr>
       			</table>
       		</div>	
			 
        	<%@include file="include/giftFormDesc.jspf"%>
	    </div>    
	</form>
</div>

<c:if test="${empty param.direct or !param.direct}">
	<c:set var="plugin_upload" value="true" scope="request"/>
	<c:set var="plugin_newUpload" value="true" scope="request"/>
	<c:set var="plugin_htmlEditor" value="true" scope="request"/>
	<c:set var="ui_accordion" value="true" scope="request"/>	
	<c:set var="ui_sortable_js" value="true" scope="request"/>
	<c:set var="ui_datepicker_js" value="true" scope="request"/>
	<c:set var="ui_datepicker_zh_CN_js" value="true" scope="request"/>
	<script type="text/javascript"	src="${ctxPath}/scripts/probiz/sales/giftForm.js?rs=${appConfig.rs}"></script>
</c:if>

<div style="display:none">
	<probiz:ui_tabs tabsId="detail" />
	<probiz:plugin_upload fileInputId="imageUrl" uploadFileTypes="gif,jpg" uploadCategory="gift" onComplete="uploadImagehandler"/>
	<!-- 
	<probiz:plugin_newUpload fileInputId="accessoryUpload" fileQueueId="accessoryfileQueue" uploadCategory="gift"  width="84" multi="true"  buttonImg="${ctxPath}/images/btn/add_attached_btn1.png" onComplete="uploadProductAccessoryhandler"/>
	 -->
	<catalog:giftCategorySelector selectorId="giftCategorySelector" callbackFunc="selectCategoryCallback"/>
</div>



<v:javascript formName="gift" staticJavascript="false" />
<script type="text/javascript">

<%--start:初始化验证与变量--%>		
	initValidate();
	//initVariables();
	weightUnit = "${weightUnit}";
	<c:choose>
		<c:when test="${not empty gift.status}">
			giftStatus = ${gift.status};
		</c:when>
		<c:otherwise>
			giftStatus = null;
		</c:otherwise>
	</c:choose>
	<%--end:初始化验证与变量--%>	
	
	<%--用ajax方法load 主要为了解决页面加载开始时候处理太多js带来的ie加载速度太慢问题。--%>
	//$j('#areaOfImages').loading().load('${ctxPath}/sales/gift/blank.html?doAction=loadAreaOfImages&giftId=${gift.giftId}',null,loadImagesCallback);
	

	//start:quickTip 生成 原因：在tag中$j无法扑捉到对象;另外直接用id指定是为了提高在ie下的查找速度
	$j('#giftName,#shortDescription,#weightMeasureUnitName').each(function(){
      	$j(this).after('<img id="'+this.id+'_tip" width="14" height="14" src="'+__ctxPath+'/images/validate/info.gif"/>');
		$j('#'+this.id+'_tip').PQuickTip({
	         source:'text',
	         title:'Help',
	         type:'help',
	         text:$j(this).attr("quickTip")
      	});
	
	});
	//end:quickTip 生成

	//start:初始化兑换的会员等级
	var membershipIds = "${gift.membership}";
	var memberships = membershipIds.split(",");	
	for(var i=0 ; i< memberships.length; i++){
		$j("#giftForm :input[name='membershipCheck']").each(
			function(){
				if(this.value == memberships[i]){
					this.checked = true;
				}
			});
	}
	//end:兑换的会员等级
	
</script>
